home *** CD-ROM | disk | FTP | other *** search
/ Programmer Plus 2007 / Programmer-Plus-2007.iso / Programming / XML Utilities / Professional Programmer XSL IDE / Xselerator25.msi / Data.Cab / F25442_TrimR.xsl < prev    next >
Encoding:
Extensible Markup Language  |  2001-10-04  |  978 b   |  32 lines

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" ><xsl:output method="xml" indent="yes"/>
  3.  
  4. <xsl:template name="TrimR">
  5.     
  6.     <!--This template will recursively trim the trailing spaces from a string-->
  7.        <xsl:param name="strInput" select="''"/>
  8.     <xsl:variable name="strLen" select="string-length($strInput)" />
  9.     <xsl:variable name="strOutput" select="substring($strInput, 1, $strLen - 1 )" />
  10.     <xsl:variable name="strLastChar" select="substring($strInput, $strLen, 1 )" />
  11.  
  12.     <xsl:choose> 
  13.      <xsl:when test="$strLastChar = ' '">    
  14.  
  15.     
  16.         <!-- At this point, the template will recursively call itself until it is trimmed -->
  17.         <xsl:call-template name="TrimR" > 
  18.             <xsl:with-param name="strInput" select="$strOutput"/>
  19.         </xsl:call-template>
  20.  
  21.  
  22.     </xsl:when>
  23.      <xsl:otherwise>
  24.             <xsl:value-of select="$strInput" />
  25.     </xsl:otherwise>
  26.     </xsl:choose>
  27.  
  28.  
  29. </xsl:template>
  30.  
  31. </xsl:stylesheet>
  32.